﻿using System;
using System.Collections.Generic;
using System.Text;

namespace PSAMMatrixCloud.Common.HttpParameterCommon
{
    /// <summary>
    /// 类名：Notify
    /// 功能：通知处理类
    /// 
    /// //////////////////////注意/////////////////////////////
    /// 调试通知返回时，可查看或改写log日志的写入TXT里的数据，来检查通知返回是否正常 
    /// </summary>
    public class HttpParameterNotify
    {
        /// <summary>
        ///  验证消息是否是调用方发出的合法消息
        /// </summary>
        /// <param name="inputPara">输入参数数组</param>
        /// <param name="app_id">appid</param>
        /// <param name="app_key">appid</param>
        /// <param name="sign">调用方生成的签名结果</param>
        /// <returns>验证结果</returns>
        public bool Verify(SortedDictionary<string, string> inputPara, string app_id, string app_key, string sign)
        {
            Dictionary<string, string> sPara = HttpParameterCore.FilterPara(inputPara);//过滤空值、sign与sign_type参数
            string mysign = HttpParameterCore.BuildMysign(sPara, app_key);//获得签名结果

            if (String.Equals(sign, mysign, StringComparison.OrdinalIgnoreCase))//验证成功
            {
                return true;
            }
            else//验证失败
            {
                return false;
            }
        }
    }
}
